<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>data</title>
    <link rel="stylesheet" href="../css/login.css">
   <script src="../js/data.js"></script>
    <style type="text/css">
        td {
            text-align: center;
            line-height: 100%;
            font-size: 20px
        }
    </style>
</head>
<body>
<script>
    //获取本月最大的天数
    var getMaxDays = function (year, month) {
        var date = new Date(year, month, 0);
        return date.getDate();
    };
    //计算某月1号是星期几
    var getWeekInMonth = function (year, month) {
        return new Date(year + '/' + month + '/' + '01').getDay();
    };
    var year = new Date().getFullYear();      // prompt("输入年分");
    var month = (new Date().getMonth() + 1);    //prompt("输入月分");
    var maxDays = getMaxDays(year, month);
    var weekInMonth = getWeekInMonth(year, month);
    //空个
    var blank;
    if (weekInMonth == 0) {
        blank = 6;
    } else {
        blank = weekInMonth - 1;
    }
    document.write(year + '年' + month + '月' + new Date().getDate() + '日')
    var html = "<table border='1px' style='width:400px;height:400px;border:solid#5bc0de;margin:10px auto'>";
    html += "<tr><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td><td>日</td></tr>";
    html += "<tr>";
    for (var b = 1; b <= blank; b++) {
        html += '<td>&nbsp;</td>';
    }
    for (var j = 1; j <= maxDays; j++) {
        if (j == new Date().getDate()) {
            html += '<td style="text-align: center ;background-color: #ac2925;color: #5bc0de">' + j + '</td>';
        } else {
            html += '<td style="text-align: center ">' + j + '</td>';
        }
        // 指定换行的条件
        if ((j + blank) % 7 == 0) {
            html += '</tr><tr>';
        }
    }
    html += "</tr>";
    html += "<table>";
    document.write(html);

</script>
<script>
    _data()
</script>
</body>
</html>